package main

import (
	"flag"
	"fmt"

	"github.com/google/gopacket"
	"github.com/google/gopacket/layers"
	"github.com/google/gopacket/pfring"
)

func main() {
	card := flag.String("c", "eth0", "network card name!")
	flag.Parse()
	fmt.Println(*card)
	if *card == "eth0" {
		fmt.Println("error")
	}
	if ring, err := pfring.NewRing(*card, 65536, pfring.FlagPromisc); err != nil {
		panic(err)
	} else if err := ring.Enable(); err != nil { // Must do this!, or you get no packets!
		panic(err)
	} else {
		packetSource := gopacket.NewPacketSource(ring, layers.LinkTypeEthernet)
		for packet := range packetSource.Packets() {
			fmt.Println(packet) // Do something with a packet here.

		}
	}
}
